package com.company;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        String names[] = new String[4];
        String dishMegs[] = new String[4];
        String addresses[] = new String[4];
        int[] times = new int[4];
        int[] states = new int[4];
        int o = 0, p = 0, q = 0;
        int a, b;
        int i = 0;
        double add[] = new double[4];
        double sum, ship;
        int num = -1; // 用户输入0返回主菜单，否则退出系统
        boolean isExit = false; // 标志用户是否退出系统： true:退出系统
        System.out.println("\n欢迎使用“吃货联盟订餐系统”");
        // 循环：显示菜单，根据用户选择的数字执行相应功能
        do {
            // 显示菜单
            System.out.println("****************************");
            System.out.println("1、我要订餐");
            System.out.println("2、查看餐袋");
            System.out.println("3、签收订单");
            System.out.println("4、删除订单");
            System.out.println("5、我要点赞");
            System.out.println("6、退出系统");
            System.out.println("****************************");
            System.out.print("请选择：");
            int choose = input.nextInt(); // 记录用户选择的功能编号
            boolean isAdd = false;  //记录是否可以订餐
            //找到要签收的订单
            //找到要删除的订单
            // 根据用户选择的功能编号执行相应功能
            switch (choose) {
                case 1:
                    // 我要订餐
                    if (i < 4) {
                        isAdd = true;
                    } else {
                        System.out.println("订餐人数过多不可以继续订餐");
                        break;
                    }
                    System.out.println("***我要订餐***");
                    System.out.println("请输入你的姓名");
                    names[i] = input.next();
                    System.out.println("序号\t菜名\t单价\t点赞数");
                    System.out.println("1\t红烧带鱼\t38.0\t" + o);
                    System.out.println("2\t鱼香肉丝\t20.0\t" + p);
                    System.out.println("3\t时令鲜蔬\t10.0\t" + q);
                    System.out.print("请输入您要点的菜品编号");
                    a = input.nextInt();
                    System.out.print("请输入您要点的菜品份数");
                    b = input.nextInt();
                    System.out.print("请输入送餐时间(送餐时间为10点至20点间整点送餐)：");
                    times[i] = input.nextInt();
                    System.out.println("请输入您的地址");
                    addresses[i] = input.next();
                    double price = 0.0;
                    switch (a) {
                        case 1:
                            price = 38.0;
                            System.out.println("您定的是红烧带鱼份数是" + b);
                            dishMegs[i] = ("红烧带鱼" + b + "份");
                            break;

                        case 2:
                            price = 20.0;
                            System.out.println("您定的是鱼香肉丝份数是" + b);
                            dishMegs[i] = ("鱼香肉丝" + b + "份");
                            break;
                        case 3:
                            price = 10.0;
                            System.out.println("您定的是时令鲜蔬份数是" + b);
                            dishMegs[i] = ("时令鲜蔬" + b + "份");
                            break;
                    }
                    System.out.println("送餐时间为" + times[i]);
                    sum = (price * b);
                    ship = 6.0;
                    if (sum > 50) {
                        ship = 0;

                    }
                    add[i] = sum + ship;
                    System.out.println("餐费：" + sum + "元" + "送餐费：" + ship + "元" + "总计："
                            + add[i] + "元");
                    i++;
                    break;
                case 2:
                    // 查看餐袋
                    System.out.println("***查看餐袋***");
                    System.out.println("序号\t订餐人\t餐品信息\t\t\t送餐地址\t总金额\t订单状态");
                    for (int j = 0; j < names.length; j++) {
                        if (names[j] != null) {
                            String state = (states[j] == 0) ? "已预订" : "已完成";
                            System.out.println((j + 1) + "\t" + names[j] + "\t" + dishMegs[j] + "\t\t\t" + addresses[j] + "\t" + add[j] + "\t" + state);
                        }

                    }

                    break;
                case 3:
                    // 签收定单
                    System.out.println("***签收定单***");
                    System.out.println("请输入菜单编号");
                    int h = input.nextInt();
                    System.out.println("请输入完成状态(0表示未完成)");
                    states[h - 1] = input.nextInt();


                    break;
                case 4:
                    // 我要删除订单
                    System.out.println("***删除订单***");

                    System.out.println("请输入菜单编号");
                    int u = input.nextInt();
                    names[u - 1] = null;
                    System.out.println("订单已删除");
                case 5:
                    // 我要点赞
                    System.out.println("***我要点赞***");
                    System.out.println("请输入菜品编号");
                    int map = input.nextInt();
                    switch (map) {
                        case 1:
                            o++;
                            break;
                        case 2:
                            p++;
                            break;
                        case 3:
                            q++;
                            break;
                    }
                    break;
                case 6:
                    // 退出系统
                    isExit = true;
                    break;
                default:
                    //退出系统
                    isExit = true;
                    break;
            } //end switch
            if (isExit == false) {
                System.out.print("输入0返回：");
                num = input.nextInt();
            } else {
                break; //退出循环
            }
        } while (num == 0);


        System.out.println("谢谢使用，欢迎下次光临！");



    }
}
